home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / tcomm6.zip / LCLIB.EXE / LCZM.H < prev    next >
Text File  |  1991-08-27  |  5KB  |  252 lines

  1. /*
  2. ** lczm.h - LiteComm ToolBox
  3. **            Copyright (c) 1991, Information Technology, Ltd.
  4. **            All rights reserved
  5. */
  6.  
  7. #ifndef _LCZM_H
  8. #define _LCZM_H
  9.  
  10. /*
  11. ** type definitions
  12. */
  13.  
  14. typedef struct
  15. {
  16.     unsigned char xxx[3];
  17.     unsigned char cmdflag;
  18. } ZRQINITREC;
  19.  
  20. typedef struct
  21. {
  22.     unsigned int  rbufsize;
  23.     unsigned char xxx;
  24.     unsigned char rflags;
  25. } ZRINITREC;
  26.  
  27. typedef struct
  28. {
  29.     unsigned char xxx[3];
  30.     unsigned char sflags;
  31. } ZSINITREC;
  32.  
  33. typedef struct
  34. {
  35.     unsigned char xflags;
  36.     unsigned char tflags;
  37.     unsigned char mflags;
  38.     unsigned char cflags;
  39. } ZFILEREC;
  40.  
  41. typedef struct
  42. {
  43.     unsigned char xxx[3];
  44.     unsigned char cack;
  45. } ZCOMMREC;
  46.  
  47. typedef union
  48. {
  49.     unsigned char H[9];
  50.     struct
  51.     {
  52.         unsigned char cmd;
  53.         union
  54.         {
  55.             ZRQINITREC     zrqi;
  56.             ZRINITREC    zri;
  57.             ZSINITREC    zsi;
  58.             ZFILEREC    zfr;
  59.             ZCOMMREC    zcr;
  60.             unsigned long P;
  61.         } u1;
  62.         union
  63.         {
  64.             unsigned long crc32;
  65.             unsigned      crc16;
  66.         } u2;
  67.     } s;
  68. } HEADER;
  69.  
  70. typedef int (*ZSENDHDR)(PROTO *, unsigned char);
  71. /*
  72. ** PROTO ctl blk, command
  73. */
  74.  
  75. typedef void(*ZSENDDATA)(PROTO *, unsigned char *, unsigned, unsigned char);
  76. /*
  77. ** PROTO ctl blk, buffer, buffer length, frame end
  78. */
  79.  
  80. typedef unsigned(*ZRECEIVE)(PROTO *, char *, int);
  81. /*
  82. ** PROTO ctl blk, buffer, buffer length
  83. */
  84.  
  85. /*
  86. ** constant definitions
  87. */
  88. #define ZBUFSIZE 1024
  89.  
  90. /* command definitions */
  91. #define ZRQINIT 0
  92. #define ZRINIT    1
  93. #define ZSINIT    2
  94. #define ZACK    3
  95. #define ZFILE    4
  96. #define ZSKIP    5
  97. #define ZNAK    6
  98. #define ZABORT    7
  99. #define ZFIN    8
  100. #define ZRPOS    9
  101. #define ZDATA    10
  102. #define ZEOF    11
  103. #define ZFERR    12
  104. #define ZCRC    13
  105. #define ZCHALLENGE 14
  106. #define ZCOMPL    15
  107. #define ZCAN    16
  108. #define ZFREECNT 17
  109. #define ZCOMMAND 18
  110. #define ZSTDERR    19
  111. #define CANCELED 20
  112. #define TIMEDOUT 21
  113. #define USERABORT 22
  114. #define DISCONNECTED 23
  115. #define ZOK        24
  116. #define ZERROR    25
  117.  
  118. /*
  119. ** header state definitions
  120. */
  121. #define GETZPAD    0
  122. #define    GETZDLE    1
  123. #define    GETFRAME 2
  124.  
  125. /*
  126. ** send file state definitions
  127. */
  128. #define WAITFORACK    1
  129. #define GOTACK        2
  130. #define SENDDHDR    3
  131. #define SENDSUBBLOCK 4
  132. #define SENDSUBEND    5
  133. #define SENDEOF        6
  134.  
  135. /*
  136. ** possible error returns from read routines
  137. */
  138. #define COMNOCARRIER -2
  139. #define COMTIMEDOUT    -3
  140. #define COMABORT    -4
  141.  
  142. /*
  143. ** rflag definitions
  144. */
  145. #define CANFDX 0x01
  146. #define CANOVIO 0x02
  147. #define CANBRK    0x04
  148. #define CANCRY    0x08
  149. #define CANLZW    0x10
  150. #define CANFC32 0x20
  151. #define ESCCTL    0x40
  152. #define ESC8    0x80
  153.  
  154. /*
  155. ** cflag definitions
  156. */
  157. #define CFEMPTY        0
  158. #define CFNOCONV    1
  159. #define CFNLTOCRLF    2
  160. #define CFRESUME    3
  161.  
  162. /*
  163. ** ZMODEM Character constants
  164. */
  165. #define ZPAD    '*'
  166. #define ZDLE    0x18
  167. #define ZDLEE    0x58
  168. #define ZBIN    'A'
  169. #define ZHEX    'B'
  170. #define ZBIN32    'C'
  171. #define ZCRCE    'h'
  172. #define ZCRCG    'i'
  173. #define ZCRCQ    'j'
  174. #define ZCRCW    'k'
  175. #define ZRUB0    'l'
  176. #define ZRUB1    'm'
  177.  
  178. #define BADCHAR    0xffff
  179.  
  180. #define GOTOR    0x100
  181. #define GOTCRCE (GOTOR|ZCRCE)
  182. #define GOTCRCG (GOTOR|ZCRCG)
  183. #define GOTCAN    (GOTOR|0x18)
  184. #define GOTCRCQ    (GOTOR|ZCRCQ)
  185. #define GOTCRCW    (GOTOR|ZCRCW)
  186.  
  187. /*
  188. ** Status codes
  189. */
  190. #define ZPKTLEN    6                            /* Packet too long */
  191. #define ZNOCAR    7                            /* Lost Carrier */
  192. #define ZXFRCAN    8                            /* Transfer cancelled */
  193. #define ZBADHDR    9                            /* Bad header received */
  194. #define ZTIMER    10                            /* Timeout */
  195. #define ZFOPEN    11                            /* Error opening file */
  196. #define ZRECOVER 12                            /* Receovering session */
  197. #define ZFCREAT    13                            /* Unable to create file */
  198. #define ZDISKERR 14                            /* Disk read/write error */
  199. #define ZBADPOS    15                            /* Positioning error */
  200. #define ZINITTO    16                            /* Timeout during initialization */
  201. #define ZSEEKERR 17                            /* File seek error */
  202. #define ZGOTFILE 18                            /* Got file header block */
  203. #define ZBADFILE 19                            /* Cant find file to send */
  204.  
  205. /*
  206. ** function prototypes
  207. */
  208. int docrc(unsigned char *, unsigned, unsigned);
  209. long docrc32(unsigned char *, unsigned, long);
  210. int swap(int);
  211. void lczinit(PROTO *, long);
  212. void sendchar(unsigned, unsigned char);
  213. int ztimedread(PROTO *);
  214. void zsendcan(unsigned);
  215. void zputstr(PROTO *, unsigned char *);
  216. void zputhex(PROTO *, unsigned char);
  217. void zsendhexheader(PROTO *, unsigned char);
  218. void zsendbytes(PROTO *, unsigned char *, unsigned);
  219. int zgetzdl(PROTO *);
  220. long zfilecrc32(PROTO *, int);
  221. unsigned receiveda16(PROTO *, char *, int);
  222. unsigned receiveda32(PROTO *, char *, int);
  223. int sendheader32(PROTO *, unsigned char);
  224. int sendheader16(PROTO *, unsigned char);
  225. void senddata32(PROTO *, unsigned char *, unsigned, unsigned char);
  226. void senddata16(PROTO *, unsigned char *, unsigned, unsigned char);
  227. int zgethex(PROTO *);
  228. int zgethexheader(PROTO *);
  229. int zgetbinaryhead(PROTO *);
  230. int zgetbinaryhead32(PROTO *);
  231. int zgetheader(PROTO *);
  232. void lczm_send(PROTO *, long, char **);
  233. void lczm_recv(PROTO *, long, char *);
  234.  
  235. /*
  236. ** global definitions used in both send/receive
  237. */
  238. extern HEADER txhdr;
  239. extern HEADER rxhdr;
  240. extern unsigned rxcount;
  241.  
  242. extern unsigned char attn[32];
  243.  
  244. /*
  245. ** function pointers
  246. */
  247. extern ZSENDHDR sendheader;
  248. extern ZSENDDATA senddata;
  249. extern ZRECEIVE receivedata;
  250.  
  251. #endif
  252.